package com.mooer.app;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.LinearGradient;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.mooer.R;
import com.mooer.http.HttpUtils;

public class BusinessGalleryItem extends Activity {

	private LinearLayout pb;

	private ImageView image;

	private String picPath;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.business_gallery_item);
		Intent intent = getIntent();
		picPath = intent.getStringExtra("picPath");
		pb = (LinearLayout) findViewById(R.id.gallery_progressbar);
		image = (ImageView) findViewById(R.id.gallery_image);
		new BitmapTask().execute("");
	}

	private class BitmapTask extends AsyncTask<String, Integer, Bitmap> {

		@Override
		protected Bitmap doInBackground(String... params) {
			Bitmap pic = HttpUtils.downloadBitmap(picPath);
			return pic;
		}

		@Override
		protected void onPostExecute(Bitmap result) {
			super.onPostExecute(result);
			if (result != null) {
				pb.setVisibility(View.GONE);
				image.setImageBitmap(result);
			} else {

			}
		}

	}

}
